<template>
    <div class="wrap normal">
        <!-- 搜索条件 -->
        <div class="wrap-form" id="wrap-form">
            <div class="left-panel">
                <el-form :inline="true" :model="form" label-width="110px" @submit.native.prevent>
                    <el-form-item label="核销用户手机号">
                        <el-input v-model="form.verificationUserMobile" placeholder="请输入" clearable style="width: 220px"></el-input>
                    </el-form-item>
                    <el-form-item label="代理商手机号">
                        <el-input v-model="form.relevanceAgentUserMobile" placeholder="请输入" clearable style="width: 220px"></el-input>
                    </el-form-item>
                    <el-form-item label="核销时间">
                        <el-date-picker v-model="form.createTimeStart" clearable type="datetime" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" placeholder="开始时间" style="width: 220px"></el-date-picker>
                        <span class="form-time-line">-</span>
                        <el-date-picker v-model="form.createTimeEnd" clearable type="datetime" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" placeholder="结束时间" style="width: 220px"></el-date-picker>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" icon="el-icon-search" @click="pageOperate('search')">查询</el-button>
                        <el-button icon="el-icon-refresh" @click="pageOperate('refresh')">刷新</el-button>
                    </el-form-item>
                </el-form>
            </div>
        </div>
        <!-- table数据 -->
        <div class="wrap-table">
            <el-table :data="tableData" :max-height="tableMaxHeight" border v-loading="tableLoading" :header-cell-style="{ background: '#F5F6FA' }">
                <el-table-column type="index" label="序号" width="50" align="center"> </el-table-column>
                <el-table-column prop="expressCardTypeName" label="快递卡类型" min-width="200"> </el-table-column>
                <el-table-column prop="expressCardCode" label="快递卡卡号" min-width="120"></el-table-column>
                <el-table-column label="核销时间" min-width="140">
                    <template slot-scope="scope">
                        {{ scope.row.verificationTime | iso8601DateTimeFormat }}
                    </template>
                </el-table-column>
                <el-table-column prop="verificationUserMobile" label="核销用户手机号" min-width="120"></el-table-column>
                <el-table-column prop="relevanceAgentUserName" label="关联代理姓名" min-width="100"></el-table-column>
                <el-table-column prop="relevanceAgentUserMobile" label="关联代理商手机号" min-width="120"></el-table-column>
                <el-table-column prop="expressCardNumber" label="总次数" min-width="100"></el-table-column>
                <el-table-column prop="expressCardUsedNumber" label="已使用次数" min-width="100"></el-table-column>
                <el-table-column prop="expressCardCanNumber" label="剩余次数" min-width="100"></el-table-column>
                <el-table-column prop="expressCardIssuedTypeName" label="分润类型" min-width="100"></el-table-column>
                <el-table-column prop="cardTotalAgentProfit" label="总利润" min-width="100"></el-table-column>
                <el-table-column prop="cardTotalIssuedAgentProfit" label="已分润金额" min-width="100"></el-table-column>
                <el-table-column prop="amountSavedMoney" label="核销用户已节省金额" min-width="140"></el-table-column>
            </el-table>
            <pagination :total="page.totalNum" :page.sync="page.pageNum" :limit.sync="page.pageSize" layout="total, sizes, prev, pager, next, jumper" @pagination="getTableData" />
        </div>
    </div>
</template>

<script>
import tableHeight from '@/mixins/tableHeight'
import { getHxCardList } from '@/api/expressCard'
export default {
    name: 'HxCard',
    mixins: [tableHeight],
    data() {
        return {
            form: {
                // 核销人手机号
                verificationUserMobile: '',
                // 代理商手机号
                relevanceAgentUserMobile: '',
                // 核销时间开始
                createTimeStart: '',
                // 核销时间结束
                createTimeEnd: ''
            },
            page: {
                pageNum: 1,
                pageSize: 10,
                totalNum: 0
            },
            tableData: [],
            tableLoading: false,
            // 类型
            operateType: '',
            // 标题
            operateTitle: '',
            // 弹框
            operateDialog: false,
            // 宽度
            operateWidth: 550,
            // loading
            operateLoading: false,
            // 操作form
            operateForm: {

            },
            operateRules: {

            },
        };
    },
    methods: {
        // 数据
        getTableData() {
            this.tableLoading = true
            const data = {
                pageNum: this.page.pageNum,
                pageSize: this.page.pageSize,
                ...this.form
            }
            getHxCardList(data).then(res => {
                this.tableLoading = false
                this.tableData = res.data.records
                this.page.totalNum = res.data.total
            }).catch(error => {
                this.tableLoading = false
            })
        },
        // 操作
        pageOperate(type, row) {
            this.operateType = type
            switch (type) {
                case 'search':
                    this.getTableData()
                    break;
                case 'refresh':
                    Object.assign(this.$data, this.$options.data())
                    this.getTableData()
                    break;
                default:
                    break;
            }
        }
    },
    mounted() {
        this.getTableData()
    }
};
</script>

<style lang="scss" scoped>
</style>